using System;
using System.Collections.Generic;
using System.Text;
using Csla.Data;

namespace MinaspetroLibrary.CurriculoPack
{
    [Serializable()]
    public class FormacaoChildInfo : Csla.ReadOnlyBase<FormacaoChildInfo>
    {
        #region Business Properties and Methods

        //declare members

        private Guid _id = Guid.NewGuid();

        private Guid _idCurriculo = Guid.NewGuid();
		
		private Guid _idCategoria = Guid.NewGuid();
		
		private Guid _idTipoFormacao = Guid.NewGuid();
		
		private Guid _idSituacao = Guid.NewGuid();

        private String _instituicao = String.Empty;
		
		private DateTime _dataInicio = DateTime.Now;
		
		private DateTime _dataFim = DateTime.Now;

        [System.ComponentModel.DataObjectField(true, true)]
        public Guid Id
        {
            get
            {
                return _id;
            }
        }


        public Guid IdCurriculo
        {
            get
            {
                return _idCurriculo;
            }
        }

        public Guid IdCategoria
        {
            get
            {
                return _idCategoria;
            }
        }
		
		public Guid IdTipoFormacao
        {
            get
            {
                return _idTipoFormacao;
            }
        }

        public Guid IdSituacao
        {
            get
            {
                return _idSituacao;
            }
        }

        public String Instituicao
        {
            get
            {
                return _instituicao;
            }
        }

        public DateTime DataInicio
        {
            get
            {
                return _dataInicio;
            }
        }

        public DateTime DataFim
        {
            get
            {
                return _dataFim;
            }
        }


        protected override object GetIdValue()
        {
            return _id.ToString();
        }

        #endregion //Business Properties and Methods

        #region Authorization Rules
        protected override void AddAuthorizationRules()
        {
            //TODO: Define authorization rules in FormacaoChildInfo

        }

        #endregion //Authorization Rules

        #region Factory Methods
        internal static FormacaoChildInfo GetFormacaoChildInfo(SafeDataReader dr)
        {
            return new FormacaoChildInfo(dr);
        }

        private FormacaoChildInfo(SafeDataReader dr)
        {
            Fetch(dr);
        }
        #endregion //Factory Methods

        #region Data Access

        #region Data Access - Fetch
        private void Fetch(SafeDataReader dr)
        {
            FetchObject(dr);
            FetchChildren(dr);
        }

        private void FetchObject(SafeDataReader dr)
        {
            _id = new Guid(dr["Id"].ToString());
            _idCurriculo = new Guid(dr["IdCurriculo"].ToString());
			_idCategoria = new Guid(dr["IdCategoria"].ToString());
			_idTipoFormacao = new Guid(dr["IdTipoFormacao"].ToString());
            _idSituacao = new Guid(dr["IdSituacao"].ToString());
            _instituicao = dr.GetString("Instituicao");
            _dataInicio = dr.GetDateTime("DataInicio");
            _dataFim = dr.GetDateTime("DataFim");
        }

        private void FetchChildren(SafeDataReader dr)
        {
        }
        #endregion //Data Access - Fetch
        #endregion //Data Access
    }
}
